/*
 * Copyright (c) 2022 HiSilicon (Shanghai) Technologies CO., LIMITED.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef __HI_RUNTIME_API__
#define __HI_RUNTIME_API__

#include "hi_type.h"
#include "hi_runtime_comm.h"

#ifdef __cplusplus
#if __cplusplus
extern "C" {
#endif
#endif /* __cplusplus */

/* ****************************************************************************
*   Prototype    : HI_SVPRT_RUNTIME_Init
*   Description  : Environment Init
*   Parameters   : HI_CHAR *pszGlobalSetting            GlobalSetting for runtime
                                                        if NULL, use default
                   HI_RUNTIME_MEM_CTRL_S *pstMemCtrl    Memory Controll by alloc,flush,and free
                                                        if NULL, use mmz
*   Return Value : HI_SUCCESS: Success; Error codes: Failure.
**************************************************************************** */
HI_S32 HI_SVPRT_RUNTIME_Init(IN const HI_CHAR* pszGlobalSetting, IN HI_RUNTIME_MEM_CTRL_S* pstMemCtrl);

/* ****************************************************************************
*   Prototype    : HI_SVPRT_RUNTIME_LoadModelGroupSync
*   Description  : Load model
*   Parameters   : HI_CHAR*                   pstModelGroupConfig    Input Group Config
                   HI_RUNTIME_GROUP_INFO_S*   pstModelGroupAttr      Group Info, such as wk,cop,connector
                   HI_RUNTIME_GROUP_HANDLE*   phGroupHandle          output Group Handle
*   Return Value : HI_SUCCESS: Success; Error codes: Failure.
**************************************************************************** */
HI_S32 HI_SVPRT_RUNTIME_LoadModelGroup(IN const HI_CHAR* pstModelGroupConfig,
    IN HI_RUNTIME_GROUP_INFO_S* pstModelGroupAttr, OUT HI_RUNTIME_GROUP_HANDLE* phGroupHandle);

/* ****************************************************************************
 * Prototype    : HI_SVPRT_RUNTIME_ForwardGroupSync
 * Description  : Perform prediction on input sample(s), and output responses for corresponding sample(s), Sync Fuction
 * Parameters   : HI_RUNTIME_GROUP_HANDLE               hGroupHandle    Group Handle generated by
 * HI_SVPRT_RUNTIME_LoadModelGroup HI_RUNTIME_GROUP_SRC_BLOB_ARRAY_PTR   pstSrc           Input Blobs
 * HI_RUNTIME_GROUP_DST_BLOB_ARRAY_PTR   pstDst           Output Blobs.
 * Return Value: HI_SUCCESS: Success; Error codes: Failure.
 * *************************************************************************** */
HI_S32 HI_SVPRT_RUNTIME_ForwardGroupSync(IN const HI_RUNTIME_GROUP_HANDLE hGroupHandle,
    IN const HI_RUNTIME_GROUP_SRC_BLOB_ARRAY_PTR pstSrc, OUT HI_RUNTIME_GROUP_DST_BLOB_ARRAY_PTR pstDst,
    IN HI_U64 u64SrcId);

/* ****************************************************************************
*   Prototype    : HI_SVPRT_RUNTIME_ForwardGroupASync
*   Description  : Perform prediction on input sample(s), and output responses for corresponding sample(s),ASync
Function
*   Parameters   : HI_RUNTIME_GROUP_HANDLE               hGroupHandle    Group Handle generated by
HI_SVPRT_RUNTIME_LoadModelGroup can't be NULL
*                  HI_RUNTIME_GROUP_SRC_BLOB_ARRAY_PTR   pstSrc      Input Blobs
*                  HI_RUNTIME_GROUP_DST_BLOB_ARRAY_PTR   pstDst      Output Blobs.
*                  HI_U64                                u64SrcId    Frame id set by user,
*                                                                    can be duplicate number
*                  HI_RUNTIME_Forward_CallBack           pCbFun      Callback for ForwardGroup,
*                                                                    can't be null
*   Return Value: HI_SUCCESS: Success; Error codes: Failure.
**************************************************************************** */
HI_S32 HI_SVPRT_RUNTIME_ForwardGroupASync(IN const HI_RUNTIME_GROUP_HANDLE hGroupHandle,
    IN const HI_RUNTIME_GROUP_SRC_BLOB_ARRAY_PTR pstSrc, OUT HI_RUNTIME_GROUP_DST_BLOB_ARRAY_PTR pstDst,
    IN HI_U64 u64SrcId, IN HI_RUNTIME_Forward_Callback pCbFun);

/* ****************************************************************************
 * Prototype    : HI_SVPRT_RUNTIME_UnloadModel
 * Description  : Unload model
 * Parameters   : HI_RUNTIME_GROUP_HANDLE   hGroupHandle           Group Handle generated by
 * HI_SVPRT_RUNTIME_LoadModelGroup can not be NULL
 *
 * Return Value : HI_SUCCESS: Success; Error codes: Failure.
 * *************************************************************************** */
HI_S32 HI_SVPRT_RUNTIME_UnloadModelGroup(IN const HI_RUNTIME_GROUP_HANDLE hGroupHandle);

/* ****************************************************************************
 * Prototype    : HI_SVPRT_RUNTIME_deInit
 * Description  : Environment DeInit
 * Return Value : HI_SUCCESS: Success; Error codes: Failure.
 * *************************************************************************** */
HI_S32 HI_SVPRT_RUNTIME_DeInit();

#ifdef __cplusplus
#if __cplusplus
}
#endif
#endif /* __cplusplus */

#endif /* __HI_RUNTIME_API__ */
